﻿<?php

//折翼天使资源社区 提供 www.zheyitianshi.com
if (!defined('IN_IA')) {
	die('Access Denied');
}
global $_W, $_GPC;
$operation = !empty($_GPC['op']) ? $_GPC['op'] : 'display';
$openid = m('user')->getOpenid();
$member = m('member')->getMember($openid);
$uniacid = $_W['uniacid'];
if ($_W['isajax']) {
	if ($operation == 'display') {
		$pindex = max(1, intval($_GPC['page']));
		$psize = 10;
		$condition = " and uid=:uid and uniacid=:uniacid and credittype=:credittype";
                if($_GPC['type']==1){
                   $credittype="gift_card"; 
                }else{
                   $credittype="gift";  
                }
		$params = array(':uniacid' => $uniacid, ':uid' => $member['uid'], ':credittype' =>$credittype);
		$list = pdo_fetchall("select * from " . tablename('mc_gifts_record') . " where 1 {$condition} order by createtime desc LIMIT " . ($pindex - 1) * $psize . ',' . $psize, $params);
		$total = pdo_fetchcolumn('select count(*) from ' . tablename('mc_gifts_record') . " where 1 {$condition}", $params);
		foreach ($list as &$row) {
			$row['createtime'] = date('Y-m-d H:i', $row['createtime']);
		}
		unset($row);
		show_json(1, array('total' => $total, 'list' => $list, 'pagesize' => $psize));
	}
}
include $this->template('member/gift_log');